<template>
    <div class="photo-container">
        <div class="top">
            <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a  v-for="item in photoMenu" :class="['mui-control-item', item.menu_id == 0 ? 'mui-active' : '']"  :key="item.menu_id" @tap="photoList(item.menu_id)">
							{{ item.title }}
						</a>
					</div>
				</div>

			</div>
        </div>

        <div>
            <ul  class="photo-list">
                <router-link tag="li" v-for="item in photolist" :key="item.id" :to="'/home/photoinfo/'+item.id">
                     <img v-lazy="item.img_url">
                     <div class="info">
                         <h1 class="info-title">{{ item.title }}</h1>
                         <div class="info-zhaiyao">{{ item.zhaiyao }}</div>
                     </div>
                </router-link>
            </ul>
        </div>
    </div>
</template>

<script>

// https://blog.csdn.net/Yw_better/article/details/101105257
import mui from '../../lib/mui/js/mui.min.js'
export default {
    created() {
        this.listMenu()
        this.photoList(0)
    },
    mounted() {
		mui('.mui-scroll-wrapper').scroll({
		    deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
    },
    data() {
        return {
            photoMenu:[],
            photolist:[],
        }
    },
    methods: {
        listMenu(){
            this.$http.get("photo/menu/find").then(result=>{
                if(result.data.code == 0){
                    this.photoMenu = result.data.data
                }else{
                    Toast("获取图片目录列表失败！")
                } 
            }, err=>{
                Toast("获取图片目录列表失败！")
            })
        },
        photoList(id){
            this.$http.get("photo/list/"+ id).then(result=>{
                if(result.data.code == 0){
                    this.photolist = result.data.data
                }else{
                    Toast("获取图片列表失败！")
                } 
            }, err=>{
                Toast("获取图片列表失败！")
            })
        }
    },
}
</script>

<style lang="less" scoped>
.photo-list{
    padding: 10px;
    padding-bottom: 0;
    
    li{
        list-style: none;
        text-align: center;
        background-color: #ccc;
        margin-bottom: 10px;
        box-shadow: 0 0 6px #999;
        position: relative;
        img[lazy=loading] {
            width: 40px;
            height: 300px;
            margin: auto;
        }
        img{
            vertical-align: middle;
            width: 100%;
        }
        .info{
            color: white;
            text-align: left;
            position: absolute;
            bottom: 0;
            max-height: 84px;
            background-color: rgba(0, 0, 0, 0.4);
            .info-title{
                font-size: 14px;
            }
            .info-zhaiyao{
                font-size: 13px;
            }

        }
    }
    
}

</style>